from datetime import datetime
from django.db import models

# Create your models here.
from users.models import UserProfile


class PayOrder(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=models.CASCADE, default='')
    out_trade_no = models.CharField(max_length=100, null=True, blank=True, verbose_name='商品订单号')
    total_amount = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, verbose_name='价格')
    trade_no = models.CharField(max_length=100, null=True, blank=True, verbose_name='支付单号')
    seller_id = models.CharField(max_length=100, null=True, blank=True, verbose_name='支付者ID')
    vip_version = models.CharField(max_length=100, null=True, blank=True, verbose_name='会员版本')
    status = models.IntegerField(default=0, choices=((0, '未支付'), (1, '已支付')), verbose_name='支付状态')
    start_time = models.DateTimeField(default=datetime.now, verbose_name='购买时间')
    finish_time = models.DateTimeField(default=datetime.now, verbose_name='到期时间')

    class Meta:
        verbose_name = "购买账单"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.out_trade_no